﻿<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <title>云协作平台-密码找回</title>
    <!-- jquery.js -->
    <script th:src="@{/js/jquery-2.2.4.min.js}"></script>
    <script th:src="@{/js/workutil.js}"></script>
    <link rel="shortcut icon" th:href="@{/images/Logo_40.png}" type="image/x-icon">
    <!-- layui.css -->
    <link th:href="@{/plugin/layui/css/layui.css}" rel="stylesheet"/>
    <!-- 本页样式 -->
    <link th:href="@{/css/index.css}" rel="stylesheet"/>
    <style>
        .api {
            position: absolute;
            bottom: 20px;
            text-align: center;
            left: 0px;
            right: 0px;
            font-size: 16px;
            color: white !important;
        }
    </style>
</head>
<body>
<div class="mask"></div>
<div class="main">
    <h1><span style="font-size: 84px;">密码找回</span></h1>
    <p id="time"></p>
    <div class="enter">
        <from class="layui-form " action="">
            <input type="hidden" th:value="${code}" name="code">
            <input type="hidden" th:value="${sessionId}" name="sessionId">
            <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-block">
                    <input type="password" name="newpassword" lay-verify="newpassword" id="newpassword"
                           autocomplete="off"
                           placeholder="请输入新密码" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" lay-verify="password" autocomplete="off" placeholder="请确认密码"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item" style="text-align: center;">
                <button class="layui-btn" lay-submit="" lay-filter="resetpass">确认修改</button>
            </div>
        </from>
    </div>
</div>
<!-- layui.js -->
<script th:src="@{/plugin/layui/layui.js}"></script>
<!-- layui规范化用法 -->
<script type="text/javascript">
    layui.define(['layer', 'form'], function (exports) {
        var form = layui.form;
        var $ = layui.jquery;

        //自定义验证
        form.verify({
            newpassword: [/^[\S]{6,12}$/, '密码必须6到12位']
            , password: function (value) {
                var repassvalue = $('#newpassword').val();
                if (value != repassvalue) {
                    return '两次输入的密码不一致!';
                }
            }
        })
        ;

        form.on('submit(resetpass)', function (data) {
            var index = layer.load(1);
            console.log(data.field);
            workUtils.ajaxPost('../../user/resetpass', data.field, function (result) {
                layer.close(index);
                workUtils.msg(result, function () {
                    console.log(result);
                    if (result.status) {
                        location.href = "../login";
                    }
                });
            });
            return false;
        });
    });
</script>
</body>
</html>